package com.yswy.backstage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yswy.backstage.service.AppProjectService;
import com.yswy.backstage.service.SoftnessService;
import com.yswy.domain.entity.AppProject;
import com.yswy.domain.entity.Softness;
import com.yswy.domain.vo.dto.BaseFilter;
import com.yswy.domain.vo.gld.addOrUpate.AppProjectAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.SoftnessAddOrUpdate;
import com.yswy.domain.vo.gld.addOrUpate.base.BaseReqVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


@RestController
@RequestMapping("/softness")
@Api(tags = "软著管理")
public class SoftnessController {
    @Autowired
    private SoftnessService softnessService;


    @PostMapping("/ListAppProject")
    @ApiOperation(value = "软著列表")
    public Page<Softness> listSoftness(@RequestBody  BaseFilter req, HttpServletRequest request) {
        return softnessService.listSoftness(req);
    }

    @GetMapping("/AllSoftness")
    @ApiOperation(value = "软著列表")
    public List<Softness> AllSoftness() {
        return softnessService.AllSoftness();
    }

    @PostMapping("/addOrUpadteSoftness")
    @ApiOperation(value = "添加修改软著")
    public void addOrUpadteSoftness(@RequestBody @Validated(BaseReqVO.CREATE.class) SoftnessAddOrUpdate req, HttpServletRequest request) {
        softnessService.addOrUpadteSoftness(req);
    }

    @GetMapping("/isExist")
    @ApiOperation(value = "判断是否存在")
    public Boolean isExist(@RequestParam(value = "softness") String softness,
                        @RequestParam(value = "softnessNo") String softnessNo,
                        HttpServletRequest request) {
        return softnessService.isExist(softness ,softnessNo);
    }

    @GetMapping("/delSoftness")
    @ApiOperation(value = "删除软著")
    public void delSoftness(@RequestParam(value = "softnessId") Long softnessId, HttpServletRequest request) {
        softnessService.delSoftness(softnessId);
    }

}
